<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="js/angular.min.js"></script>
</head>
<body>
   <!--
       $http:请求服务的方法
        (1)get(url)
       （2）post(url)
       （3）jsonp(url)
       $http:读取服务器数据的方法
       (1)success()  error()
       (2)then()
   -->
 <div ng-app="myApp" ng-controller="myCon">
     <button ng-click="net()">点击发送get网络请求</button>
     <button ng-click="pos()">点击发送post请求</button>
     <ul>
         <li ng-repeat="x in datas">{{x}}</li>
     </ul>
 </div>
 <script type="text/javascript">
     angular.module("myApp",[]).controller("myCon",function ($scope,$http) {
         //点击发送get网络请求
         $scope.net=function () {
             //借助服务发起请求
             //TODO 借助服务$http发送的get请求
             $http.get("data/jsonon").success(function (response) {
                 //请求成功
                      console.log(response);
                      console.log(typeof response);
                      $scope.datas=response;
             }).error(function (obj) {
                 //请求失败
                  document.write(obj);
             });
         };
        //点击发送post请求
       $scope.pos=function () {
          $http.post("data/jsonone").then(function (obj) {
              //在then回调函数中传递回来的服务器数据，在回调参数的data字段里面包裹着
              console.log(obj.data);
              $scope.datas=obj.data;
          });


       }


     });




 </script>
</body>
</html>